package com.kolalo.base;

import java.util.List;

public class string {
	public static final String Empty = "";
	public String Value;
	public int Length;
	public char[] values;

	protected static final String NullMessage= "java.lang.String类型的参数不能为null";
	protected static final String ListNullMessage= "java.util.List类型的参数不能为null";
	public string(String value) throws Exception {
		if(value==null) throw new Exception(NullMessage);
		this.Value = value;
		Length=this.Value.length();
		values=this.Value.toCharArray();
	}

	/**
	 * 判断字符串是否为null 空串
	 * @param value 需要做判断传入的字符串
	 * @return true
	 */
	public static boolean IsNullOrEmpty(String value) {
		return value == null || value.isEmpty();
	}

	/**
	 * 判断字符串是否为null 空串  空格
	 * @param value 需要做判断传入的字符串
	 * @return
	 */
	public static boolean IsNullOrWhiteSpace(String value) {
		return IsNullOrEmpty(value) || value.replaceAll("\\s+", "").isEmpty();
	}

	/**
	 * 连接字符串
	 * @param args 字符串列表
	 * @return 返回串联字符串
	 * @throws Exception 传入的参数中存在null时将抛出异常
	 */
	public static String Concat(String... args) throws Exception {
		StringBuilder stringBuilder = new StringBuilder();
		for (String arg : args) {
			if (arg == null) {
				throw new Exception(NullMessage);
			}
			stringBuilder.append(arg);
		}
		return stringBuilder.toString();
	}

	public static String Copy(String value) {
		return new String(value.toCharArray());
	}

	/**
	 * 比较两字符串是否相等
	 * @param strA
	 * @param strB
	 * @return
	 */
	public static boolean Equals(String strA,String strB) {
		return strA.equals(strB);
	}

	/**
	 * 比较两字符串是否相等 并忽略大小写
	 *
	 * @param strA
	 * @param strB
	 * @return
	 */
	public static boolean EqualsIgnoreCase(String strA, String strB) {
		return strA.equalsIgnoreCase(strB);
	}

	public static String Join(String separator,String ... values) {
		//if (separator == null)throw new Exception(ListNullMessage);
		//if(values==null)separator=Empty;
		//if(values.size()<1)return Empty;
		//StringBuilder stringBuilder=new  StringBuilder();
		//for (int i = 0; i < values.size(); i++) {
		//	stringBuilder.append(values.get(i));
		//	if(i+1<values.size())stringBuilder.append(separator);
		//}
		// return stringBuilder.toString();
		return String.join(separator,values);
	}


}
